$(function(){
        // don't forget this init!      
        $.initWindowMsg();
        
        var childWin;
        $('#presenter-button').click(function(){
          childWin = window.open('/phoenix/controller/selectuser?type=presenter','child', "width=500, height=500, location=no, menubar=no, scrollbars=no, status=no, toolbar=no");
          if (window.focus) {childWin.focus()}
        });
        
        $('#producer-button').click(function(){
            childWin = window.open('/phoenix/controller/selectuser?type=producer','child', "width=500, height=500, location=no, menubar=no, scrollbars=no, status=no, toolbar=no");
            if (window.focus) {childWin.focus()}
          });

        // set up the message handlers, listen for events 'childMsg1' and 'childMsg2'     
        $.windowMsg("set-presenter-name", function(message) {
          $('#presenter-text').val(message);
        });
        $.windowMsg("set-presenter-uid", function(message) {
            $('#presenter-id').val(message);
        });
        $.windowMsg("set-producer-name", function(message) {
          $('#producer-text').val(message);
        });
        $.windowMsg("set-producer-uid", function(message) {
            $('#producer-id').val(message);
        });

        $(':button').click(function(){
        	var row =  $(this).attr('class');
        	console.log("selecting row " + row);
            value = $('#' + row).val();
            console.log("selected uid " + $('#' + row).attr("data-uid"));
            uid =  $('#' + row).attr("data-uid");
            console.log("data " + value);
            var type = $('#type').val();
            console.log("type " + type);
            if(type == "presenter"){
	            $.triggerParentEvent("set-presenter-name", value);
	            $.triggerParentEvent("set-presenter-uid", uid); 
            }
            else if (type == "producer"){
            	$.triggerParentEvent("set-producer-name", value);
   	            $.triggerParentEvent("set-producer-uid", uid);
            }
          });
        
      });  